﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Sockets;
using Pixysoft.Framework.Sockets.Controller;

namespace Pixysoft.Framework.Sockets.Core
{
    public delegate void SocketMessageReceived(ISocketIoSession session, IProtocolMessage[] messages);

    class ClientSocketIoSession : SocketIoSession
    {
        public event SocketMessageReceived OnSocketMessageReceived;

        public ClientSocketIoSession(ISessionEncoder encoder, ISessionDecoder decoder, Socket socket)
            : base(encoder, decoder, socket)
        {
        }

        protected override void MessageReceived(IProtocolMessage[] messages)
        {
            if (OnSocketMessageReceived != null)
                OnSocketMessageReceived(this, messages);
        }

        public static ClientSocketIoSession CreateSession(ISessionEncoder encoder, ISessionDecoder decoder, Socket socket)
        {
            return new ClientSocketIoSession(encoder, decoder, socket);
        }
    }
}
